<!--
 * @Author: yanjikun
 * @Date: 2021-05-28 13:53:25
 * @LastEditors: yanjikun
 * @LastEditTime: 2022-06-08 11:58:04
 * @Description: file content
-->
<template>
  <ConfigProvider v-bind="bindValues">
    <router-view #="{ Component }">
      <component :is="Component" />
    </router-view>
  </ConfigProvider>
</template>
<script lang="ts" setup>
  import { useTitle } from '@vueuse/core'
  import { ConfigProvider } from 'ant-design-vue'
  import { watchEffect } from 'vue'
  import { useRoute } from 'vue-router'
  import { PROJECT_CONFIG } from './enums/cacheEnums'
  import { useConfigProvider } from './hooks/useConfigProvider'
  import { useProjectStore } from './store/modules/projectConfig'
  import { storage } from './utils/Storage'
  const bindValues = useConfigProvider()
  const route = useRoute()
  const projectStore = useProjectStore()
  storage.get(PROJECT_CONFIG) ?? projectStore.initBasicInfo()

  watchEffect(() => {
    if (route.meta?.title) {
      /**设置网页标题 */
      useTitle(`${projectStore.basicInfo.platform} · ${route.meta.title}`)
      /**替换系统logo */
      document.getElementsByTagName('link').namedItem('logo')!.href = projectStore.basicInfo.logo
    }
  })
</script>

<style lang="less" scoped></style>
